class fragments::gitlab(Boolean $install_from_source) {
  include apt
  apt::key { 'gitlab-ce-key':
        id => 'E15E78F4',
        source => 'https://packages.gitlab.com/gpg.key'
  }
  if ! $install_from_source {
    apt::source { 'gitlab-ce-sources':
      location => 'https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu',
      repos => 'main',
      require => Apt::Key['gitlab-ce-key']
    }
    package { 'gitlab-ce':
      ensure => present,
      require => Apt::Source['gitlab-ce-sources'],
    }
  }

  apt::source { 'gitlab-runner-sources':
    location => 'https://mirrors.tuna.tsinghua.edu.cn/gitlab-ci-multi-runner/ubuntu',
    repos => 'main',
    require => Apt::Key['gitlab-ce-key']
  }
  package { 'gitlab-ci-multi-runner':
    ensure => present,
    require => Apt::Source['gitlab-runner-sources']
  }
  user { 'gitlab-runner':
    ensure => present,
    groups => ['tomcat8'],
    require => Package['gitlab-ci-multi-runner','tomcat8']
  }
}
